//
//  AboutProductViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//
//实现思路
//1.上方一个头view   2.中间一个cell(可以返回多个)  3.一个尾view
#import "AboutProductViewController.h"
#import "AboutProductViewCell.h"
#import <SVProgressHUD.h>
@interface AboutProductViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation AboutProductViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //使用tablevView
    UITableView *AboutProductTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 375, 667)];
                                            //style:UITableViewStyleGrouped];
    //cell高
    AboutProductTableView.rowHeight = 50;
 
    //设置不能滚动
    AboutProductTableView.scrollEnabled = NO;
    
    //添加
    [self.view addSubview:AboutProductTableView];
    
    //设置代理
    AboutProductTableView.delegate = self;
    AboutProductTableView.dataSource = self;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    //返回组
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    //返回行
    
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //加载cell
    AboutProductViewCell *cell = [[AboutProductViewCell alloc]initWithAboutProduct:indexPath];
    
    
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    //一个头view上面放了两张图
    UIView *view1 = [[UIView alloc]init];
    view1.backgroundColor = [UIColor whiteColor];
    
    //图
    UIImageView *imageview = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_img_logo_nor.png"]];
    imageview.frame = CGRectMake(150, 50, 65, 85);
    [view1 addSubview:imageview];
    
    UIImageView *imageviewlable = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    imageviewlable.frame = CGRectMake(150, 150, 65, 40);
    [view1 addSubview:imageviewlable];
    
    return view1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    //头高
    return 250;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    //一个尾view上放两个label
    UIView *view = [[UIView alloc]init];
    
   // view.backgroundColor = [UIColor whiteColor];
    
    
    //交流label
    UILabel *QQlabel = [[UILabel alloc]initWithFrame:CGRectMake(100, 190, 300, 40)];
    QQlabel.text = @"用户交流群:  972388597";
    QQlabel.textColor = [UIColor blueColor];
    [view addSubview:QQlabel];
    
    //版本label
    UILabel *versionlabel = [[UILabel alloc]initWithFrame:CGRectMake(140, 220, 200, 40)];
    versionlabel.text = @"version : 1.4.0";
    versionlabel.textColor = [UIColor blueColor];
    [view addSubview:versionlabel];
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    //尾高
    return 280;
}
//点击用户协议事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //取消选中状态
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    switch (indexPath.row) {
           //成功
        case 0:
          
            // 遮布显示时间
            [SVProgressHUD setMinimumDismissTimeInterval:0.1];
            
            //遮布
            [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
            
            //成功+的字
            [SVProgressHUD showSuccessWithStatus:@"打开用户协议"];
           
        break;
    }
    
}
@end